// Copyright (C) joyinter
// All rights reserved.
// 
// Author : Jiang Li
// Date   : 2004-11-22

// last update 2005-8-11 luxizhu

#ifndef __MENU_H_COMMON_UI__
#define __MENU_H_COMMON_UI__

#pragma once

#pragma once
#include "listview.h"

class CJoyMenu;

//##ModelId=44C4B6030177
class CJoyMenuItem : public CJoyListViewItem
{
public:
	//##ModelId=44C4B603017A
    CJoyImagePtr    m_icon;
	//##ModelId=44C4B6030187
    CStringW        m_text;
	//##ModelId=44C4B603018B
    UINT            m_id;

	//##ModelId=44C4B603018C
    virtual void CM_MouseLeave();
	//##ModelId=44C4B603018E
    virtual void CM_MouseHover();
	//##ModelId=44C4B6030197
    virtual void CM_Mouse(MouseMessage msg, const CPoint& pt);
	//##ModelId=44C4B603019B
    virtual void CM_Draw(Graphics& graph);

public:
	//##ModelId=44C4B60301A5
    CJoyMenuItem();
	//##ModelId=44C4B60301A6
    virtual ~CJoyMenuItem();

	//##ModelId=44C4B60301B5
    CJoyMenu* GetMenu()
    {
        return (CJoyMenu*)m_listView;
    }
};

//##ModelId=44C4B60301E4
class CJoyMenu :
    public CJoyListView
{
	DECLARE_DYNAMIC(CJoyMenu)
protected:

	//##ModelId=44C4B60301E9
    static CJoyMenu* m_hookMenu;
	//##ModelId=44C4B60301F4
    static HHOOK    m_mouseHook;
	//##ModelId=44C4B60301F5
    static LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam);

	//##ModelId=44C4B6030205
    CJoyMenuItem* CreateItem();
	//##ModelId=44C4B6030206
	void SetBorder(HWND hWnd,BOOL bBorder);

	//##ModelId=44C4B6030214
    virtual void CM_LoadSkin(CJoyXmlElement* pSkinElem);
public:
	//##ModelId=44C4B6030222
    int m_iconMargin;
	//##ModelId=44C4B6030223
    int m_iconSize;
	//##ModelId=44C4B6030232
    int m_textMargin;
	//##ModelId=44C4B6030233
	int m_nTrackedID;
public:
	//##ModelId=44C4B6030234
    CJoyMenu(void);
	//##ModelId=44C4B6030242
    virtual ~CJoyMenu(void);

	//##ModelId=44C4B6030245
    bool Create();
	//##ModelId=44C4B6030246
    void Show(int x, int y);
	
	//##ModelId=44C4B6030251
	HANDLE CreatePopupMenu();
	//##ModelId=44C4B6030252
	BOOL AppendMenu (UINT nFlags,UINT nIDNewItem = 0,LPCTSTR lpszNewItem = NULL);
	//##ModelId=44C4B6030262
	BOOL AppendMenu (UINT nFlags,UINT nIDNewItem,const CBitmap* pBmp );
	//##ModelId=44C4B6030271
	BOOL AppendMenu (UINT nFlags,UINT nIDNewItem,Image* pImage );
	//##ModelId=44C4B6030280
	int TrackPopupMenu (UINT nFlags,int x,int y,CWnd* pWnd,LPCRECT lpRect = 0 ); 
	//##ModelId=44C4B6030291
	int TrackPopupMenuEx (UINT nFlags,int x,int y,CWnd* pWnd,LPCRECT lpRect = 0 ); 	

public:
    DECLARE_MESSAGE_MAP()
	//##ModelId=44C4B60302A1
    afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	//##ModelId=44C4B60302B0
    afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
	//##ModelId=44C4B60302B4
    afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	//##ModelId=44C4B60302C1
    afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
	//##ModelId=44C4B60302CE
    afx_msg void OnSize(UINT nType, int cx, int cy);
	//##ModelId=44C4B60302D3
    afx_msg void OnClose();
	//##ModelId=44C4B60302D5
	afx_msg void OnTimer(UINT nIDEvent);
	//##ModelId=44C4B60302E0
	afx_msg void OnPaint();
	//##ModelId=44C4B60302E2
	afx_msg void OnDestroy();
	//##ModelId=44C4B60302E4
	int SelectID(void);
};

#endif  // __MENU_H_COMMON_UI__
